package com.neuedu.inner;

public class Outer2 {



    //属性
    private String name;

    //方法

    public void method(){
        System.out.println("Outer.method");
        new Outer2.InnerClass().innerMethod();
    }

    public static void main(String[] args) {
        System.out.println(new Outer2().name);

        new Outer2().method();

        //使用Outer.Inner inn=new Outer.Inner()方式实例化静态内部类。

        //内部类调用
        new InnerClass().innerMethod();

        //匿名内部类
       new Thread(){
            public void run() {
                while (true){
                    System.out.println(System.currentTimeMillis());
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }.start();






    }

    static class InnerClass{

        public void innerMethod(){
            System.out.println("InnerClass.innerMethod");
        }
    }


}
